package com.baidu.process.scheduled;

import com.baidu.process.chat.core.web.service.IEvaluationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时删除sessionId过期数据
 *
 * @author lws
 * @date 2022-11-14
 */
@Slf4j
@Component
public class EvalDelPushDataScheduled {

    private final IEvaluationService evalResultService;

    public EvalDelPushDataScheduled(IEvaluationService evalResultService) {
        this.evalResultService = evalResultService;
    }

    @Scheduled(cron = "${eval.timer.cron}")
    public void sendMsgSessionOverTime() {
        log.info("删除满意度评价sessionId过期数据,开始");
        long startTime = System.currentTimeMillis();
        try {
            evalResultService.del(null);
        } catch (Exception e) {
            log.error("定时删除满意度评价sessionId过期数据异常", e);
        }
        log.info("删除满意度评价sessionId过期数据,结束耗时:{}" + (System.currentTimeMillis() - startTime));
    }
}

